<template>
  <div id="app">
    <Tobar :key="topbarKey"></Tobar>
    <Header></Header>
    <router-view @updateTopBarKey="topbarKeyFn" />
    <Footer></Footer>
    <Login v-show="isShowLoginModal"></Login>
    <transition>
      <Toast v-show="isShowToast"></Toast>
    </transition>
  </div>
</template>

<script>
import Tobar from "@/components/Tobar";
import Header from "@/components/Header";
import Footer from "@/components/Footer";
// 导入登录框
import Login from "@/components/Login.vue";
// 导入显示隐藏辅助函数
import { mapState } from "vuex";

// import axios from '@/requset/requset'
import { JingpinAPI } from "@/requset/api";

import Toast from "@/components/Toast.vue";

export default {
  data() {
    return {
      topbarKey: 0,
    };
  },
  components: {
    Tobar,
    Header,
    Footer,
    Login,
    Toast,
  },
  async created() {
    //  JingpinAPI().then(res=>{
    //     console.log(res);
    //   })
    let res = await JingpinAPI();
    // console.log("res3:", res);

    console.log('配置值为',process.env.VUE_APP_BASE_URL);
    console.log('配置值为',process.env.VUE_APP_MY_TEXT);
  },
  computed: {
    ...mapState({
      isShowLoginModal: (state) => state.showModal.isShowLoginModal,
      isShowToast: (state) => state.showToast.isShowToast,
    }),
  },
  watch: {
    "$route.path": {
      handler(newVal, oldVal) {
        if (newVal != oldVal) {
          this.topbarKey++;
        }
      },
    },
  },
  methods: {
    topbarKeyFn() {
      this.topbarKey++;
    },
  },
};
</script>


<style lang="less">
#app {
}
</style>
